import VueRouter from 'vue-router';
import routes from "./router.js";

// 遍历路由规则数组
routes.forEach(item=>{
    // 找到系统管理页面
    if (item.name==="system") {
        var childNode = [
            {
            // 教师管理 
            name:"Teacher",
            path:"/teacher",
            component:()=>import("@/layout/components/Main"),
            meta:{title:"教师管理",icon:"iconfont icon-jiaoshiguanli"},
            children:[
                {
                    // 教师列表
                    name:"teacherList",
                    path:"/teacher/teacherList",
                    meta:{title:"教师列表"},
                    component:()=>import("@/views/teacher/list/index")
                },
                {
                    // 信息统计
                    name:"information",
                    path:"/teacher/information",
                    meta:{title:"信息统计"},
                    component:()=>import("@/views/teacher/information/index")
                },
            ]
        },
        {
            // 学生管理
            name:"student",
            path:"/student",
            component:()=>import("@/layout/components/Main"),
            meta:{title:"学生管理",icon:"iconfont icon-xueshengguanli-01"},
            children:[
                {
                    // 学生列表
                    name:"studentlist",
                    path:"/student/studentlist",
                    meta:{title:"学生列表"},
                    component:()=>import("@/views/student/list/index")
                },
                {
                    // 学生意向
                    name:"studentintention",
                    path:"/student/studentintention",
                    meta:{title:"学生意向"},
                    component:()=>import("@/views/student/intention/index")
                },
            ]
        },
        {
            // 院系管理
            name:"department",
            path:"/department",
            component:()=>import("@/layout/components/Main"),
            meta:{title:"院系管理",icon:"iconfont icon-yuanxiguanli"},
            children:[
                {
                    // 院系列表
                    name:"departmentlist",
                    path:"/department/departmentlist",
                    meta:{title:"院系列表"},
                    component:()=>import("@/views/departments/list/index")
                },
            ]
        },
        {
            // 班级管理
            name:"class",
            path:"/class",
            component:()=>import("@/layout/components/Main"),
            meta:{title:"班级管理",icon:"iconfont icon-banjiguanli"},
            children:[
                {
                    // 班级列表
                    name:"classlist",
                    path:"/class/classlist",
                    meta:{title:"班级列表"},
                    component:()=>import("@/views/class/list/index")
                },
            ]
        },
        {
            // 课程管理
            name:"Course",
            path:"/course",
            component:()=>import("@/layout/components/Main"),
            meta:{title:"课程管理",icon:"iconfont icon-d"},
            children:[
                {
                    // 课程列表
                    name:"courselist",
                    path:"/course/ccourselist",
                    meta:{title:"课程列表"},
                    component:()=>import("@/views/course/list/index")
                },
                {
                    // 课程排课
                    name:"courseArranging",
                    path:"/course/courseArranging",
                    meta:{title:"课程排课"},
                    component:()=>import("@/views/course/arrang/index")
                },
            ]
        },
        {
            // 成绩管理
            name:"Score",
            path:"/score",
            component:()=>import("@/layout/components/Main"),
            meta:{title:"成绩管理",icon:"iconfont icon-d"},
            children:[
                {
                    // 成绩列表
                    name:"scorelist",
                    path:"/score/scorelist",
                    meta:{title:"成绩列表"},
                    component:()=>import("@/views/score/list/index")
                },
                {
                    // 成绩录入
                    name:"scoreentry",
                    path:"/score/scoreentry",
                    meta:{title:"成绩录入"},
                    component:()=>import("@/views/score/list/index")
                },
            ]
        },
        {
            // 教材管理
            name:"material",
            path:"/material",
            component:()=>import("@/layout/components/Main"),
            meta:{title:"教材管理",icon:"iconfont icon-jiaocaiguanli"},
            children:[
                {
                    // 教材列表
                    name:"materiallist",
                    path:"/material/materiallist",
                    meta:{title:"教材列表"},
                    component:()=>import("@/views/material/list/index")
                },
            ]
        },
        {
            // 寝室管理
            name:"dormitory",
            path:"/dormitory",
            component:()=>import("@/layout/components/Main"),
            meta:{title:"寝室管理",icon:"iconfont icon-jiaocaiguanli"},
            children:[
                {
                    // 寝室列表
                    name:"dormitorylist",
                    path:"/dormitory/dormitorylist",
                    meta:{title:"寝室列表"},
                    component:()=>import("@/views/dormitory/list/index")
                },
                {
                    // 楼栋列表
                    name:"storey",
                    path:"/dormitory/storey",
                    meta:{title:"楼栋列表"},
                    component:()=>import("@/views/dormitory/storey/index")
                },
            ]
        },
        {
            // 作品管理
            name:"production",
            path:"/production",
            component:()=>import("@/layout/components/Main"),
            meta:{title:"作品管理",icon:"iconfont icon-zuopin"},
            children:[
                {
                    // 作品列表
                    name:"productionlist",
                    path:"/production/productionlist",
                    meta:{title:"作品列表"},
                    component:()=>import("@/views/production/list/index")
                },
            ]
        },
        {
            // 满意度调查表管理
            name:"satisfaction",
            path:"/satisfaction",
            component:()=>import("@/layout/components/Main"),
            meta:{title:"满意度调查管理",icon:"iconfont icon-manyidutiaocha"},
            children:[
                {
                    // 满意度调查列表
                    name:"satisfaction",
                    path:"/satisfaction/satisfaction",
                    meta:{title:"满意度调查列表"},
                    component:()=>import("@/views/satisfaction/list/index")
                },
            ]
        },]
        // 连接两个数组，并重新赋值给子节点
        item.children = item.children.concat(childNode);
    }
});

//插件路由器
const router = new VueRouter({
    //配置路由规则
    routes,
    // 采用历史模式
    // mode:"history"
});

export default router
